import request from '@/utils/request'

const api = {
  login: 'web/un_login/phone_pass_login', // 登录
  userInfo: 'web/teacher/info_v2', // 获取用户全部信息
  setDefaultArea: 'web/home/change_area', // 修改园区
  setDefaultStaffPosition: 'web/teacher/set_default_role', // 设置员工岗位
  sms: 'sso/web/un_login/send_sms', // 验证码
  forgetPassword: 'sso/web/un_login/forget_password',
  modifyPassword: 'web/un_login/modify_password' // 修改密码
  // modifyPassword: 'sso/web/staff/modify_password' // 修改密码
}

export function login (params = {}) {
  return request({
    url: api.login,
    method: 'post',
    params
  })
}

export function getUserAllInfo (params = {}) {
  return request({
    url: api.userInfo,
    method: 'post',
    params
  })
}

export function setStaffPosition (params = {}) {
  return request({
    url: api.setDefaultStaffPosition,
    method: 'post',
    params
  })
}

export function setStaffArea (params = {}) {
  return request({
    url: api.setDefaultArea,
    method: 'post',
    params
  })
}

export function forgetPassword (params = {}) {
  return request({
    url: api.forgetPassword,
    method: 'post',
    params
  })
}

export function modifyPassword (params = {}) {
  return request({
    url: api.modifyPassword,
    method: 'get',
    params
  })
}

export function sendSms (params = {}) {
  return request({
    url: api.sms,
    method: 'post',
    params
  })
}

export function logout (data = {}) {
  return request({
    url: api.pass,
    method: 'POST',
    data
  })
}

export function phoneCreate (mobile) {
  return request({
    url: `web/children/getPublicKey?mobile=${mobile}`,
    method: 'get'
  })
}
